package marchsoft.modules.tiku.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import marchsoft.modules.tiku.entity.ESafeType;
import marchsoft.base.BasicMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

/**
* <p>
* 安全类别 Mapper 接口
* </p>
*
* @author zsy
* @since 2022-03-29
*/
@Component
public interface ESafeTypeMapper extends BasicMapper<ESafeType> {
    @Select("SELECT * FROM e_safe_type WHERE is_deleted=0")
    IPage<ESafeType> getAllPage(IPage<Object> page);

    @Delete("<script>" +
            "DELETE FROM e_safe_type WHERE id IN " +
            "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    @Results(value = { @Result(column = "id", property = "id") })
    int deleteType(@Param("ids") Set<Long> ids);

    @Update("UPDATE e_safe_type SET is_show=#{isShow} WHERE id=#{id}")
    int updateStatus(ESafeType eSafeType);

    @Select("SELECT name FROM e_safe_type WHERE is_show=1 AND is_deleted=0")
    List<ESafeType> getAllName(ESafeType eSafeType);

    @Select("SELECT * FROM e_safe_type WHERE is_show=1 AND is_deleted=0")
    List<ESafeType> getFront(ESafeType eSafeType);
}
